import request from './request';

/**
 * 获取招聘列表
 * @param {Object} params - 查询参数
 * @param {number} params.page - 页码
 * @param {number} params.pageSize - 每页条数
 * @param {string} params.keyword - 关键词
 * @returns {Promise}
 */
export function listRecruitments(params) {
  return request({
    url: '/recruitment',
    method: 'get',
    params
  });
}

/**
 * 发布招聘
 * @param {Object} data - 招聘信息
 * @param {string} data.title - 职位名称
 * @param {string} data.description - 职位描述
 * @param {number} data.departmentId - 部门ID
 * @param {string} data.requirements - 职位要求
 * @param {number} data.count - 招聘人数
 * @param {string} data.deadline - 截止日期
 * @returns {Promise}
 */
export function createRecruitment(data) {
  return request({
    url: '/recruitment',
    method: 'post',
    data
  });
}

/**
 * 获取招聘详情
 * @param {number} id - 招聘ID
 * @returns {Promise}
 */
export function getRecruitment(id) {
  return request({
    url: `/recruitment/${id}`,
    method: 'get'
  });
}

/**
 * 更新招聘
 * @param {number} id - 招聘ID
 * @param {Object} data - 招聘信息
 * @returns {Promise}
 */
export function updateRecruitment(id, data) {
  return request({
    url: `/recruitment/${id}`,
    method: 'put',
    data
  });
}

/**
 * 删除招聘
 * @param {number} id - 招聘ID
 * @returns {Promise}
 */
export function deleteRecruitment(id) {
  return request({
    url: `/recruitment/${id}`,
    method: 'delete'
  });
}